Component({
  data: {
    selected: 0,
    color: "#7A7E83",
    selectedColor: "#1296db",
    list: [
      {
        pagePath: "/pages/index/index",
        text: "首页",
        iconPath: "/static/images/tabbar/home.png",
        selectedIconPath: "/static/images/tabbar/home-active.png",
        number: "",
      },
      {
        pagePath: "/pages/goods/goods",
        text: "商品",
        iconPath: "/static/images/tabbar/goods.png",
        selectedIconPath: "/static/images/tabbar/goods-active.png",
        number: "",
      },
      {
        pagePath: "/pages/logs/logs",
        text: "",
        iconPath: "/static/images/tabbar/home.png",
        selectedIconPath: "/static/images/tabbar/home-active.png",
        number: "",
      },
      {
        pagePath: "/pages/notice/notice",
        text: "消息",
        iconPath: "/static/images/tabbar/notice.png",
        selectedIconPath: "/static/images/tabbar/notice-active.png",
        number: "",
      },

      {
        pagePath: "/pages/mine/mine",
        text: "我的",
        iconPath: "/static/images/tabbar/mine.png",
        selectedIconPath: "/static/images/tabbar/mine-active.png",
        number: "",
      },
    ],
    // background: '../static/tabbar-bg.png',
    centerImg: "/static/images/tabbar/cart.png",
  },
  // attached() {
  //     if (this.data.selected == 2) {
  //         this.setData({
  //             centerImg: '/static/icon/xinjian.png'
  //         })
  //     } else {
  //         this.setData({
  //             centerImg: '/static/icon/xinjian.png'
  //         })
  //     }
  //     let numi = 'list[3].number'
  //     this.setData({
  //         [numi]: 12
  //     })
  // },

  methods: {
    // 切换 tab 事件
    switchTab(e) {
      const data = e.currentTarget.dataset;
      const path = data.path;
      const index = data.index;

      // 跳转页面
      if (index != 2) {
        wx.switchTab({
          url: path,
        });
      } else {
        wx.navigateTo({
          url: "/pages/cart/cart",
        });
      }
    },
  },
});
